package com.meichis.yndms.model;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Objects;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2022-05-17 15:44
 */
public class BusinessBoard implements Serializable {

    //品牌
    private String sbuBrand = "";

    //销售金额
    private String salesAmount = "";

    //进货额
    private double amount = 0;

    //仓库名称
    private String storageName = "";

    //仓库ID
    private String storageId = "";

    //库存件数
    private String quantity = "";


    public String getSbuBrand() {
        return sbuBrand;
    }

    public void setSbuBrand(String sbuBrand) {
        this.sbuBrand = sbuBrand;
    }

    public String getSalesAmount() {
        return salesAmount;
    }

    public void setSalesAmount(String salesAmount) {
        this.salesAmount = salesAmount;
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public String getStorageName() {
        return storageName;
    }

    public void setStorageName(String storageName) {
        this.storageName = storageName;
    }

    public String getStorageId() {
        return storageId;
    }

    public void setStorageId(String storageId) {
        this.storageId = storageId;
    }

    public String getQuantity() {
        return quantity;
    }

    public void setQuantity(String quantity) {
        this.quantity = quantity;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BusinessBoard board = (BusinessBoard) o;
        return Objects.equals(storageId, board.getStorageId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(storageId);
    }


    public static class CategoryComparatorQuantity implements Comparator<BusinessBoard> {

        @Override
        public int compare(BusinessBoard s1, BusinessBoard s2) {
            if (s1.getQuantity().contains("件") && s2.getQuantity().contains("件")) {
                double b1 = Double.parseDouble(s1.getQuantity().replace("件", ""));
                double b2 = Double.parseDouble(s2.getQuantity().replace("件", ""));

                if ((b2 - b1) > 0) {
                    return 1;
                } else if (b2 - b1 < 0) {
                    return -1;
                } else {
                    return 0;
                }
            } else {
                return 0;
            }
        }
    }

    public static class CategoryComparatorAmount implements Comparator<BusinessBoard> {

        @Override
        public int compare(BusinessBoard s1, BusinessBoard s2) {


            if ((s2.getAmount() - s1.getAmount()) > 0) {
                return 1;
            } else if (s2.getAmount() - s1.getAmount() < 0) {
                return -1;
            } else {
                return 0;
            }
        }
    }

    public static class CategoryComparatorSalesAmount implements Comparator<BusinessBoard> {

        @Override
        public int compare(BusinessBoard s1, BusinessBoard s2) {


            if ((Double.parseDouble(s2.getSalesAmount()) - Double.parseDouble(s1.getSalesAmount())) > 0) {
                return 1;
            } else if ((Double.parseDouble(s2.getSalesAmount()) - Double.parseDouble(s1.getSalesAmount())) < 0) {
                return -1;
            } else {
                return 0;
            }
        }
    }
}

